import Vue from 'vue'
import VueRouter from 'vue-router'
import Page1 from '../views/Page1.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/p1',
    name: 'Page1',
    component: Page1
  },
  {
    path: '/p2/:userId',
    name: 'Page2',
    props: true,
    component: () => import('../views/Page2.vue')
  },
  {
    path: '/p3',
    name: 'Page3',
    component: () => import('../views/Page3.vue')
  },
  {
    path: '/layout',
    component: () => import('../components/Layout.vue'),
    children: [
      {
        name: 'l-page1',
        path: '',
        component: () => import('../views/Page1.vue')
      },
      {
        name: 'l-page3',
        path: 'l3',
        component: () => import('../views/Page3.vue')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
